@extends('common.base-master')

@section('html-head')
    <link rel="stylesheet" type="text/css" href="{{url('slick/slick.css')}}"/>
    <script src="{{url('js/mui.min.js')}}"></script>
    <script type="text/javascript" src="{{url('js/hmt.js')}}" ></script>
    <script src="{{url('slick/slick.js')}}" type="text/javascript" ></script>
    <script type="text/javascript" src="{{url('js/shopcar.js')}}" ></script>
    <script type="text/javascript" src="{{url('js/alertPopShow.js')}}"></script>
    <!--插件-->
    <link rel="stylesheet" href="{{url('css/swiper.min.css')}}">
    <link rel="stylesheet" type="text/css" href="{{url('css/common.css')}}"/>

    <!-- Noty 提示框的js集成 -->
    <script src="{{ url('vendor/noty-2.2.9/packaged/jquery.noty.packaged.js') }}"></script>
    <script src="{{ url('vendor/noty-2.2.9/themes/bootstrap.js') }}"></script>
    <script src="{{ url('vendor/noty-2.2.9/options.js') }}"></script>
    <style>
        .change-doctor{
            width: 1.8rem;
            height: 0.7rem;
            border: 1px solid #c7712b;
            color: #c7712b;
        }
    </style>
@endsection

@section('html-body')
    <header class="mui-bar mui-bar-nav report-header box-s" id="header" style="background-color: #FFFFFF">
        <a href="javascript:history.go(-1)"><i class="iconfont icon-fanhui fl"></i></a>
        <p>全部订单</p>
    </header>
    <div class="mui-clearfix" style="padding-top: 0px;">
        <div class="order-top clearfloat" style="background-color: #afaba7;">
            <ul>
                <li class="clearfloat @if((int)$model == 0)cur @endif"><a href="{{route('M.Doctor.orderList')."?model=0"}}">全部</a></li>
                <li class="clearfloat @if((int)$model == 1)cur @endif"><a href="{{route('M.Doctor.orderList')."?model=1"}}">门诊</a></li>
                <li class="clearfloat @if((int)$model == 2)cur @endif"><a href="{{route('M.Doctor.orderList')."?model=2"}}">面诊</a></li>
            </ul>
        </div>
        @if($orders && $orders !== null)
            @foreach($orders as $order)
                <div class="order-list clearfloat">
                    <p class="ordernum box-s">
                        订单  {{$order->order_num}}
                        @if((int)$order->status == 0)
                            <span style="background-color: #00CD66">待使用</span>
                        @else
                            <span style="background-color: #ABABAB">已结束</span>
                        @endif
                    </p>
                    <div class="list clearfloat fl box-s">
                        <a href="">
                            <div class="tu fl clearfloat">
                                <img src="{{route('Api.Image.Show',['id'=>$order->img_id])}}"/>
                            </div>
                            <div class="middle clearfloat fl">
                                <p class="tit">{{$order->title}}</p>
                                <p class="fu-tit">下单时间：{{$order->created_at}}</p>
                                <p class="fu-tit">就诊地点：{{$order->hospital}}</p>
                                <p class="price clearfloat">
                                    <span class="xprice fl">¥{{$order->order_price}}</span>
                                </p>
                            </div>
                        </a>
                    </div>
                    <div style="display: flex;padding: 2%">
                        <span style="width: 70%;font-size: .4rem; line-height: .6rem;color: red;">
                            就诊时间：<?php echo mb_substr($order->bespoke_time,0,10)?> @if($order->bespoke_slot == 'am')上午@elseif($order->bespoke_slot == 'pm')下午 @endif
                        </span>
                        @if((int)$order->status == 0)
                        <span style="width: 30%">
                            <button style="border:1px solid #ea8219;padding: 0.2rem;color: #ea8219" class="btn_wan" data-id="{{$order->id}}">订单完成</button>
                        </span>
                        @endif
                        <div>
                            <button class="change-doctor" id="btn_referral" data-id="{{$order->order_num}}" style="font-size: .15rem">转诊</button>
                        </div>
                    </div>

                </div>
            @endforeach
        @endif
        <style type="text/css">
            .more-btn{width: 25%; padding: 3% 0; text-align: center; background-color: #00CC7D; color: #fff; font-size: .5rem; margin: 5% auto;}
        </style>
    </div>
    <script>
        $(function(){
            $('.btn_wan').click(function(){
                var id = $(this).attr('data-id');
                $.ajax({
                    url:"{{route('Api.Order.confimOrder')}}",
                    type:'post',
                    dataType:'json',
                    data:{id:id},
                    success:function(obj){
                        if(obj.level == "success"){
                            noty({text:obj.message,type:obj.level,timeout:600,
                                callback:{
                                    afterClose:function(){
                                        window.location.reload();
                                    }
                                }
                            });
                        }else{
                            noty({'type':'error','text':obj.message,timeout:600});
                        }
                    },
                    error:function(obj){
                        var datajson = obj.responseJSON;
                        noty({'type':'error','text':datajson.message,timeout:600});
                    }
                });
            });

            $('#btn_referral').click(function () {
               var orderNum = $('#btn_referral').data('id');
               window.location.href="{{route('M.Doctor.referral')}}?order_num="+orderNum;
            });
        });
    </script>
@endsection